package com.reflex.mian;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {

	public static void main(String[] args) throws IllegalAccessException, InvocationTargetException, InstantiationException {
		Class<?> clazz = Person.class;
		Field[] field = clazz.getDeclaredFields();
		
		Method[] methods = clazz.getDeclaredMethods();
		for(Field f : field) {
			try {
				if(f.getName().equals("age")) {
					f.setAccessible(true);
					System.out.println(f.getInt(clazz.newInstance()));
				}
			} catch (IllegalArgumentException | InstantiationException e) {
				e.printStackTrace();
			}
		}
		
		for(Method method : methods) {
			Object obj = method.invoke(clazz.newInstance(),  null);
			System.out.println(method.getName()+"-----"+obj);
		}
	}
}
